<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">	
	function downloadAttachment(fileUrl,fileName){
		var form = document.createElement("form");
		form.action = "${basePath}/downloadAttachments";
		form.method = "post";
		form.target = "_blank";
		form.style.display = "none";
		var input = document.createElement("input");
		var input1 = document.createElement("input");
		input.name = "url";
		input.type = "hidden";
		input.value = fileUrl;
		input1.name = "fileName";
		input1.type = "hidden";
		input1.value = fileName;
		
		form.appendChild(input);
		form.appendChild(input1);
		
		document.body.appendChild(form);
		
		form.submit();
		document.body.removeChild(form);
	}
</script>
</head>
<body>
	<div class="am-u-sm-12 am-u-md-10 am-u-lg-8 am-u-md-centered am-u-lg-centered am-cf">
		<article class="am-article">
		<div class="am-article-hd">
			<h1 class="am-article-title">${article.title}
				<c:if test="${!empty article.subTitle }">
					<p class="am-article-meta">${article.subTitle}</p>
				</c:if>
			</h1>
			<p class="am-article-meta">共被浏览&nbsp;${article.viewCounts}次</p>
			<fmt:formatDate value="${article.insertTime}"
				pattern="yyyy-MM-dd" var="insertTime" />
			<fmt:formatDate value="${article.updateTime}"
				pattern="yyyy-MM-dd HH:mm:ss" var="updateTime" />
			<p class="am-article-meta">${article.insertUser}&nbsp;发布于&nbsp;${insertTime}</p>
			<c:if test="${updateTime != insertTime}">
				<p class="am-article-meta">再编辑于&nbsp;${updateTime}&nbsp; 共修改过${article.updateCounts }次</p>
			</c:if>
			<c:if test="${!empty article.industry }">
				<div class="am-article-lead am-margin-vertical">
					<div class="am-container">
						<div class="am-u-sm-4 am-u-md-3 am-u-lg-2">
							<span class="am-article-meta">行业分类</span>
						</div>
						<div class="am-u-sm-8 am-u-md-9 am-u-lg-10">
							<p>${article.industry}</p>
						</div>
					</div>
					<c:if test="${!empty article.subIndustry }">
						<div class="am-container">
							<div class="am-u-sm-4 am-u-md-3 am-u-lg-2">
								<span class="am-article-meta">行业子分类</span>
							</div>
							<div class="am-u-sm-8 am-u-md-9 am-u-lg-10">
								<p>${article.subIndustry}</p>
							</div>
						</div>
					</c:if>
				</div>
			</c:if>
			<c:if test="${!empty article.imagePath }">
				<div class="am-article-lead am-margin-vertical">
					<span class="am-article-meta">封面</span>
					<p><img src="${article.imagePath }" style="max-width: 500px;"/></p>
				</div>
			</c:if>
		</div>
		<c:if test="${!empty article.provider }">
			<div class="am-article-bd">
				<p class="am-article-lead">提供者：${article.provider }</p>
			</div>
		</c:if>
		<c:if test="${!empty article.description }">
			<div class="am-article-bd">
				<p class="am-article-lead">${article.description }</p>
			</div>
		</c:if>
		<div class="am-article-bd">
			${article.content}
		</div>
		</article>
		<c:if test="${!empty article.attachments}">
			<c:forEach items="${article.attachments }" var="a"
				varStatus="status">
				<div class="preview am-u-sm-12 am-form-group">
					<label class="am-u-sm-2 am-form-label am-text-right">附件 </label>
					<div class="am-u-sm-4">
						<c:choose>
							<c:when test="${fn:length(a.fileName) > 20}">
								<c:set var="fileName"
									value="${fn:substring(a.fileName, 0, 20)}..." />
							</c:when>
							<c:otherwise>
								<c:set var="fileName" value="${a.fileName}" />
							</c:otherwise>
						</c:choose>
						<span style="text-align: center; font-size: 1.6rem;" title="${a.fileName }"> ${fileName } </span>
					</div>
					<div class="am-u-sm-2 am-u-end">
						<button type="button"
							onclick="downloadAttachment('${fn:replace(a.filePath,'\\','/' )}','${a.fileName }')"
							class="am-btn am-btn-default am-btn-sm">
							<i class="am-icon-download">附件下载 </i>
						</button>
					</div>
				</div>
			</c:forEach>
		</c:if>
	</div>

	</div>
	<div class="am-form-group am-text-center" style="margin-top: 20px">
		<button type="button" class="am-btn am-btn-primary am-btn-xs"
			onclick="article.close()">返回</button>
	</div>
</body>
</html>
